#include <sys/socket.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <stdio.h>
#include <stdlib.h>

#define FRAME_LEN 1518

int main(){
	int s; /*socketdescriptor*/

	s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
	if (s == -1) { 
		printf("ERR: Failed to create socket\n");
		return -1;
	}
	void* buffer = (void*)malloc(FRAME_LEN); /*Buffer for ethernet frame*/
	int length = 0; /*length of the received frame*/ 
	length = recvfrom(s, buffer, FRAME_LEN, 0, NULL, NULL);
	if (length == -1) { 
		printf("Failed to recieve buffer\n");
	}
	printf("%d ",length);
	
	return 0;
}
